package TestClass1;

    //----------------------------------创建对象-----------------------------------------
    //可创建多个对象
    //eg. pubilc class teacher{}
public class Student {
    //对成员变量进行封装
    private String name;
    private double chinese;
    private double math;
    private double score;//如果这里加上语文成绩和数学成绩会是0

    public void PrintTotalScore(){
        System.out.println(name+"的总分为："+(chinese+math));
    }
    public void PrintAverageScore(){
        System.out.println(name+"的平均成绩为："+(chinese+math)/2.0);
    }

    //-----------------------------------this关键字------------------------------
    public void PrintThis(){
        System.out.println(this);
    }
    //this指向当前对象地址
    public void PrintPAss(double socre) {
        double score=150;
        this.score=chinese+math;
        if (this.score > score){//this.score指的是当前对象中的score
            System.out.println(name+"能被录取");
        }
        else System.out.println(name+"未能被录取");
    }

    //----------------------------------构造器--------------------------------------
    //完成初始化
    public Student(String name,double score) {
        this.name=name;
        this.score=score;
    }
    public Student()
    {
        //若写了构造器，就必须要写无参数的，否则new Student（）时 报错
    }
    //-------------------------------封装-----------------------------------------
    //使用 private 封装后，用方法来实现输入输出
    public void SetIn(String name,double chinese,double math){
        this.name=name;
        if (chinese>=0 && chinese<=100 && math>=0 && math<=100) {
            this.chinese=chinese;
            this.math=math;
        }
        else System.out.println(name+"成绩输入错误~");
    }
    public double GetScore() {
        return this.score;
    }
    public String GetName(){
        return this.name;
    }
}
